#include "GenSlopeOperator.h"
#include "DlgGenSlope.h"
#include "HDiMineModel.h"
#include "hdimineview.h"

CGenSlopeOperator::CGenSlopeOperator(HDiMineView* view,IDMAddIn*addin)
:CAddInBaseOperator(view,addin)
{
}

CGenSlopeOperator::~CGenSlopeOperator(void)
{
}
int CGenSlopeOperator::Init()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	if(!CAddInBaseOperator::Init()) return 0;
	m_addin=(CAddInName*)GetIDMAddIn();
	if(m_addin->m_opStep!=2)
	{
		AfxMessageBox(sp_check_layer_name);
		return 0;
	}
	dmDbLayer* contourLayer=m_pView->GetModel()->GetActiveFile()->GetLayerFromName(STRING_CONTOUR);
	if(contourLayer->GetEntitiesCount()<1)
	{
		AfxMessageBox(sp_check_layer_name);
		return 0;
	}
	CGenSlopeDialog* genSlope=new CGenSlopeDialog;
	

	BEGIN_VALIDATE
	VALIDATE(!!genSlope)
	VALIDATE(genSlope->DoModal()==1)

	EXIT_VALIDATE
	if(genSlope) delete genSlope;
	RETURN_VALIDATE_RESULT
}